/**
 * This class is the main view for the application. It is specified in app.js as the
 * "mainView" property. That setting automatically applies the "viewport"
 * plugin causing this view to become the body element (i.e., the viewport).
 *
 * TODO - Replace this content of this view to suite the needs of your application.
 */
Ext.define('DragonApp.view.main.Main', {
    extend: 'Ext.container.Container',
    plugins: 'viewport',
    xtype: 'app-main',

    requires: [
        'DragonApp.view.main.Header', //页眉
        'DragonApp.view.main.Footer', //页脚
        'DragonApp.view.main.Panel', //主区域
        'DragonApp.view.main.Controller', //主页控制器
        'DragonApp.view.main.ViewModel', //主页数据
        'DragonApp.view.menu.MenuTree', //导航面板
        'Ext.plugin.Viewport'
    ],

    controller: 'main',
    viewModel: {
        type: 'main'
    },
    layout: {
        type: 'border'
    },
    items: [{
            xtype: 'appheader',
            region: 'north',
            itemId: 'toobar'
        },
        {
            xtype: 'menutree',
            region: 'west',
            margin: '37 0 0 0',
            rootVisible: false,
            width: 200
        }, {
            region: 'center',
            xtype: 'mainpanel'
        }, {
            xtype: 'appfooter',
            region: 'south'
        }
    ],
    listeners: {
        beforerender: function(me) {
            //工具栏赋值
            var tbar = me.items.first();

            var tbar_user = tbar.queryById('user');
            var tbar_role_name = tbar.queryById('role_name');

            tbar_user.setText(sessionStorage.getItem('DragonApp_user'));
            tbar_role_name.setText(sessionStorage.getItem('DragonApp_role_name'));
        }
    }
});